modeling - Power Law in Excel works better than R? -


i trying model data. having better luck excel r, excel solution won't scale need figure how in r.

excel map trendline data , power curve yields reasonable y = 0.6462x^-0.542.

when put same data r , try model continuous power-law in powerlaw package y = 0.14901x^-3.03671. intercept way small , alpha way big.

# 14 days of % of users retained y = c(0.61431   , 0.42585   , 0.35427   , 0.33893   , 0.28853   , 0.26004   , 0.2352    , 0.20087   , 0.17969   , 0.1848    , 0.17311   , 0.17092   , 0.15777   , 0.14901)  y.pl = conpl$new(y) y.pl_est = estimate_xmin(c_pl) y.pl_est  # $ks # 0.1068587 # # $xmin # 0.14901 # # $pars # 3.03673 # # $ntail # 14 

image shows how models built 14-days of data excel , r conpl() match actuals out day 60

is there way use lm or glm power curve give reasonable intercept , alpha?

i haven't used powerlaw package, r's base nls (non-linear least squares) function gives results similar got excel. if there difference, after checking code errors, first thought "so worse excel" :).

# data dat = data.frame(x=1:14, y = c(0.61431   , 0.42585   , 0.35427   , 0.33893   , 0.28853   , 0.26004   , 0.2352    , 0.20087   , 0.17969   , 0.1848    , 0.17311   , 0.17092   , 0.15777   , 0.14901))  # model m1 = nls(y ~ a*x^b, list(a=1,b=1), data=dat) summary(m1)  formula: y ~ * x^b  parameters:   estimate std. error t value pr(>|t|)        0.62104    0.01307   47.51 4.94e-15 ***   b -0.51460    0.01525  -33.74 2.92e-13 ***  # plot nls model curve(coef(m1)[1]*x^coef(m1)[2], from=1, to=14)  # add curve excel model in red curve(0.6462*x^(-0.542), from=1, to=14, col="red", lty=2, add=true)  # add data points points(dat$x, dat$y) 

enter image description here


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -