sachsmc / cosinor Goto Github PK
View Code? Open in Web Editor NEWR package for estimation and prediction of the cosinor model for periodic data
License: Other
R package for estimation and prediction of the cosinor model for periodic data
License: Other
I noticed that cosinor does not work with tidy dataframes:
dat <- readr::read_csv(data_location)
class(dat) # "tbl_df" "tbl" "data.frame"
mod <- cosinor.lm(y ~ time(time), period = 1440, data = dat)
This gives an error:
Error in model.frame.default(formula = newformula, data = data, na.action = na.action, :
invalid type (list) for variable 'rrr'
The error occurs in this line:
data$rrr <- cos(2 * pi * data[, timevar]/period) # from body(cosinor.lm)
Running just this line for my data set gives the error message:
Error: Unsupported index type: function
I don't know if this should be the responsibility of the user or not... Please ignore this if that is the case!
Using lmer or lme, See R code in the appendix of Albert & Hunsberger, Biometrics (2005).
Out < −nlme(conc ∼ (A + exp(B) ∗
(C ∗ cos(2 ∗ pi ∗ (time + D + exp(E)/(1 + exp(E))))
+ F ∗ cos(4 ∗ pi ∗ (time + G + exp(E)/(1 + exp(E)))))),
data = dataset,
fixed = list(A ∼ Group, B + E ∼ −1 + Group, C + D + F + G ∼ 1), random=A+B+E∼Group|ID,
start = c(1.8, .2, .1, .2, .5, .1, .2, .1),
control = list(maxIter = 100, returnObject = T))
Dear Michael,
I am hoping to use the function ggplot.cosinor.lm to plot multiple cosinors. I have looked into the source code of this function to see if I can extend the accepted covariates beyond 0 and 1. However, I am quite new to cosinor analysis and very new to R!
Looking at the source code, I believe what I would like to extend is this section here:
`for(j in covars){
newdata[,j] <- 0
}
if(!is.null(x_str)){
for(d in x_str){
tdat <- newdata
tdat[,d] <- 1
newdata <- rbind(newdata, tdat)
}
newdata$levels <- ""
for(d in x_str){
newdata$levels <- paste(newdata$levels, paste(d, "=", newdata[,d]))
}
}`
I thought I could change it such that tdat[,d] <- d
and this would mean that d in (x_str)
would take all values in x_str
from 0 to 20 (or however many). But this returned an error: 'variable x_str was fitted with type numeric but type character was supplied'. So I think I messed something up.
Rather than having a covariate of values 0 or 1 (two 'groups') like in the vitamind set, I would like to extend this to more than two groups. Is this possible, or am I missing some fundamental principle?
Thanks in advance, and many thanks for writing this package in the first place :)
Victoria
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.