Dear R-users,

I am trying to understand how the 'segmented'-package works to determine 
breakpoints and slopes of regression lines in broken-line regression models.
However, I am not able to repeat the example on the "plant"-dataset, 
which was reported in the accompanying paper of the package. (V.M.R 
Muggeo, "Segmented: an R package to fit regression models with 
broken-line relationships")

I would be grateful for any ideas, why this function is not working the 
way it was described in the paper. The error message points to a wrong 
length of row- and dimnames. Unfortunately this doesn't help me very 
much in understanding the function, if it does not work on the example data.

Do you think the error will be somewhere in the function, or is it my 
stupidity?
I am using R version 2.15.1 and the package was built in 2.15.2, but in 
respect to the error message I cannot imagine that this will cause my 
problems.


Below you will find the code as it was reported in the paper:

library(segmented)

data("plant")
attach(plant)

X <- model.matrix(~0 + group)*time

time.KV <- X[,1]
time.KW <- X[,2]
time.WC <- X[,3]

olm <- lm(y~0+ group + time.KV + time.KW + time.WC)

os <- segmented(olm, seg.Z= ~ time.KV + time.KW + time.WC, 
psi=list(time.KV=c(300,500), time.KW=c(450,600), time.WC=c(300,450)))


The error message is as follows:

Error in `rownames<-`(`*tmp*`, value = c("psi1.time.KV", "psi2.time.KV",  :
   Length of 'dimnames' [1] not equal to array extent
Zusätzlich:Warnmeldung:
In cbind(initial, psi, sqrt(vv)) :
   number of rows of result is not a multiple of vector length (arg 2)



However, when I take out one break.point from any of the groups (e.g. 
time.KV=300), the function works fine without reporting any errors:

code as follows:
os <- segmented(olm, seg.Z= ~ time.KV + time.KW + time.WC, 
psi=list(time.KV=300, time.KW=c(450,600), time.WC=c(300,450)))


Thanks alot for your comments.
Best regards,

Benedikt




-- 
Benedikt Drosse

PhD student
AG von Korff
Max Planck Institute for Plant Breeding Research
Dept. Plant Developmental Biology
Carl-von-Linné-Weg 10
50829 Cologne
Germany


	[[alternative HTML version deleted]]


