polyfit: Fit Polynomial Functions of Time-lag and Time

Description Usage Arguments Value Examples

View source: R/polyfit.R

Description

polyfit returns results of fitting polynomial or indicator functions of time or time-lag function.

Usage

1
polyfit(data,time,degree=2,plot=TRUE,title="",xlabel="",ylabel="",indicator,index=1,intercept="TRUE",pch.plot=19,lwd.fit=2,lty.fit=2)

Arguments

data

a data frame (or matrix) with n rows for subjects and T columns for the repeated measurements.

time

a vector with T equally or unequally spaced time points.

degree

positive integer indicating the order of the polynomial function. The default is 2.

plot

a logical indicating whether observed and fitted values be plotted or not. The default is TRUE.

title

a character string indicating title of the profile plot. The default is blank.

xlabel

a character string indicating label for the x-axis. The default is blank.

ylabel

a character string indicating label for the y-axis. The default is blank.

indicator

a logical indicating whether an indicator function of time will be used or not. The default is FALSE.

index

a positive integer indicating the time point(s) or lag at which indicator should be 1. It is 0 for all other time points. The default is 1.

intercept

a logical indicating whether intercept term should be included in the indicator model or not. The default is TRUE.

lwd.fit

integer for line width of the estimated average. The default is 2.

lty.fit

integer for line width of the estimated average. The default is 2.

timepch.plot

a integer indicating type of symbols to be used in plot. The default is 19 for a solid dot.

Value

Plot of observed and fitted model id plot is TRUE and summary of the fitted linear model. More specifically,

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
data(Tcells)
time <- c(0, 2, 4, 6, 8, 18, 24, 32, 48, 72)
j <- 4
n <- 44
gene.names <- c("FYB", "CD69", "IL2RG", "CDC2")
degree.order <- c(4,4,3,3)
par(mfrow=c(2,2))
for(i in 1:j){
 data.gene <- Tcells[,seq(i, ncol(Tcells), j)]
 mean.gene <- apply(data.gene,2,mean)
 polyfit(mean.gene,time,degree=degree.order[i],plot=TRUE,title=gene.names[i],xlabel="Time points",ylabel="Expression Response",indicator=FALSE,index=1,intercept=TRUE,pch.plot=19,lwd.fit=2,lty.fit=2)
 legend("bottomright",legend=c("observed","fitted"),col=c("black","red"),lty=c(1,2),lwd=c(2,2),cex=0.75)
}

priyakohli5/MLGM documentation built on April 24, 2021, 4:22 p.m.