Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8194273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:46:00+00:00 2026-06-07T04:46:00+00:00

I am trying to plot a power law line to fit x and y

  • 0

I am trying to plot a power law line to fit x and y data that I already have in a data frame. I have tried power.law.fit in the igraph library but it isn’t working. The data frame is:

dat=data.frame(
  x=1:8,
  ygm=c( 251.288, 167.739, 112.856, 109.705, 102.064, 94.331, 95.206, 91.415)
)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:46:03+00:00Added an answer on June 7, 2026 at 4:46 am

    I generally use one of two strategies here, I take the log and fit a linear model or I use nls. I think you could figure out the logged model if you wanted to, so Ill show the nls method here.

      nls1=nls(ygm~i*x^-z,start=list(i=-3,z=-2),data=dat)
    

    Double check that is the formula you want, this method accepts a pretty broad class of formulas. Spend some time fooling with starting values. In particular try to think of frontiers where the likelihood surface could do weird things. Try values on both sides of the wierd places so you can be assured that you are not in a local optima.

    > nls1
    Nonlinear regression model
      model:  ygm ~ i * x^-z 
       data:  dat 
           i        z 
    245.0356   0.5449 
     residual sum-of-squares: 811.4
    
     ... 
    
    > predict(nls1)
    [1] 245.03564 167.95574 134.66070 115.12256 101.94200  92.30101  84.86458
    [8]  78.90891
    > plot(dat)
    > lines(predict(nls1))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to plot out GPS data that is given to me in Hour
I am trying to plot some data in Flot that should display x-axis in
I am trying to plot Banknote data frame from alr3 package.My pairs function throws
I'm trying to plot real-time graph, with time axis, but I have found the
I am trying plot data sets consisting of 3 coordinates: X-coordinate, x-coordinate and the
I am trying to plot a graph using gnuplot. I have six text files.
I am trying to plot this kind of behaviour of a data set. I
I am trying to plot some data using pylab scatter function. I'm using pylab.scatter(X,
I am trying to plot some test data (show at the end of this
I am trying to plot a linear regression line on a scatter plot. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.