Giter Site home page Giter Site logo

cosinor's People

Contributors

sachsmc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cosinor's Issues

cosinor.lm does not work with tidy dataframes.

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!

Implement mixed effects cosinor model

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))

Extension of ggplot.cosinor.lm

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.