I am working with single case data (SCAN package). Within the Scan package, I am using the plm() function for conducting a piecewise linear regression. However, my outcome variable (moderate-to-vigorous physical activity) is not normally distributed, so I, ideally better not use the 'gaussian' family in the command.

My dependent variable (physical activity) is measured in minutes/day, which is considered to have a natural zero (implying complete inactivity or the absence of any physical activity). It does not depict frequencies or proportions. I did a Shapiro-Wilk normality test, showing my dependent variable is not normal, and the histogram shows a right skewed distribution. When trying another distribution in the command, both the inverse.gaussian as the gamma distributions are not working, because positive values only are allowed for the 'inverse.gaussian' family and non-positive values not allowed for the 'Gamma' family.

I tried to transform my variable from gamma distribution to normal distribution. But still bump into errors; Somebody mentioned the following: 'The error occurs when you are trying to predict infinite values. If you have zero values than the data are not gamma distributed as this would imply an infinite low probability of such a value occurring.'

Is there somebody that can provide help, please? :-)

Dataframe = P001_impt Variable in my dataframe I'm interested in (as dependent variable): imptd_MVPA_bts10

R command:

*gamma_vector <- P001_imptd$imptd_MVPA_bts10 normal_vector <- gamma2norm(gamma_vector, mu = 38.45181, sd = 38.59228, shape = 38.4518072289157, rate = 0.1) P001_imptd$imptd_MVPA_bts10_transformed <- normal_vector hist(imptd_MVPA_bts10_transformed)

scedPA_001_imptd <- readSC("P001_imptd.csv", cvar = "case", dvar = "imptd_MVPA_bts10_transformed", pvar = "Phase", mvar = "prog_day")

plm_001_imptd <- plm (scedPA_001_imptd, dvar = "imptd_MVPA_bts10_transformed", pvar = "Phase", mvar = "prog_day", model = "W", family = "gaussian", trend = TRUE, level = TRUE, slope = TRUE, contrast_level = "preceding", contrast_slope = "preceding") plm_001_imptd*

==> Error: scdf has dependent variable 'imptd_MVPA_bts10_transformed' but not all cases have a variable named 'imptd_MVPA_bts10_transformed'.

0

There are 0 best solutions below