Reputation: 95
I am having an issue with the segmented package in R. The issue is when I use the davies.test and segmented.default. The code I am working with is as follows:
library(segmented)
library(survey)
data(api)
dstrat<-svydesign(id=~1,strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)
o<-svyglm(api00~ell, design=dstrat)
#specify as a string the objective function to be minimized. It can be obtained via svyvar()
fn.x<- 'as.numeric(svyvar(resid(x, "pearson"), x$survey.design, na.rm = TRUE))'
os<-segmented.default(o, ~ell, control=seg.control(fn.obj=fn.x, display=TRUE))
slope(os)
davies.test(os, ~ell)
I get this error: Error in eval(predvars, data, env) : object 'api00' not found. I am new to the segmented package and I do not know how to fix this. I tried the svyglm object "o" and I still get the same error. What am I missing?
Upvotes: 0
Views: 18