powersolve_general {OptHoldoutSize} | R Documentation |
General solver for power law curve
Description
Find least-squares solution: MLE of (a,b,c) under model
y_i = a x_i^-b + c + e_i
;
e_i~N(0,y_var_i)
Try a range of starting values and refine estimate.
Slower than a single call to powersolve()
Usage
powersolve_general(x, y, y_var = rep(1, length(x)), ...)
Arguments
x |
X values |
y |
Y values |
y_var |
Optional parameter giving sampling variance of each y value. Defaults to 1. |
... |
further parameters passed to optim. We suggest specifying lower and upper bounds for (a,b,c); e.g. lower=c(1,0,0),upper=c(10000,3,1) |
Value
List (output from optim
) containing MLE values of (a,b,c)
Examples
# Retrieval of original values
A_true=2000; B_true=1.5; C_true=0.3; sigma=0.002
X=1000*abs(rnorm(10000,mean=4))
Y=A_true*(X^(-B_true)) + C_true + rnorm(length(X),sd=sigma)
c(A_true,B_true,C_true)
powersolve_general(X[1:10],Y[1:10])$par
powersolve_general(X[1:100],Y[1:100])$par
powersolve_general(X[1:1000],Y[1:1000])$par
[Package OptHoldoutSize version 0.1.0.0 Index]