powersolve {OptHoldoutSize} | R Documentation |
Fit 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)
Usage
powersolve(
x,
y,
init = c(20000, 2, 0.1),
y_var = rep(1, length(y)),
estimate_s = FALSE,
...
)
Arguments
x |
X values |
y |
Y values |
init |
Initial values of (a,b,c) to start. Default c(20000,2,0.1) |
y_var |
Optional parameter giving sampling variance of each y value. Defaults to 1. |
estimate_s |
Parameter specifying whether to also estimate s (as above). Defaults to FALSE (no). |
... |
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(X[1:10],Y[1:10])$par
powersolve(X[1:100],Y[1:100])$par
powersolve(X[1:1000],Y[1:1000])$par
powersolve(X[1:10000],Y[1:10000])$par
[Package OptHoldoutSize version 0.1.0.0 Index]