On 2/19/2008 2:22 PM, Benjamin Zuckerberg wrote:
> 
> I am encountering an error when I attempt to reference a glm model  
> within a function.  The function uses the segmented.glm command  
> (package = segmented).  Within the segmented.glm command one specifies  
> an object, in this case a logistic regression model, and specifies a  
> starting threshold term (psi).  I believe this is an environment  
> problem, but I do not have a solution.  Any assistance would be  
> greatly appreciated.  The function is as follows:
> 
>> colonization <- function(x,y){
> library(segmented)
>       col <- subset(final,final[,x] == 2 | final[,x] == 4)
>       col[,x] <- ifelse(col[,x] == 2,1,0)
>       glm1 <- glm(col[,x]~col[,"PLAND"],family=binomial)
>       glm2 <- segmented.glm(obj = glm1, seg.Z = ~PLAND, psi=y, it.max = 100)
> }
>> colonization("PIWO",48)
> 
> Error in eval(expr, envir, enclos) : object "x" not found

You could use traceback() to find the location of the error, but I would 
suspect it's a bug in segmented.glm.  You should contact the maintainer 
of that package (Vito Muggeo) to work it out.  (I've cc'd him.)

Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to