Learn R Programming

Actigraphy (version 1.4.0)

cat_flm_plot: Plot Functional Linear Model Analysis Results of a Categorical Type

Description

This function produce either one or two plots: An effect of a categorical (factor) covariate on activity values by time and potentially the F-test for the effect of the categorical covariate.

Usage

cat_flm_plot(smoothdata, matchresults, flmresults, ftest, 
	nperm, lb, xat, varname, col, ylim, L, xlab="Time", ylab="Activity")

Arguments

smoothdata

List output from the fda.smoothdata function

matchresults

List output from the matchid function.

flmresults

List output from the flm_cate function.

ftest

A logic value indicating whether to implement F test or not. F test will be implement if ftest is TRUE.

nperm

The number of permutations for the F-test.

lb

X axis labels.

xat

X axis label positions.

varname

Name of categorical covariate.

col

Colors for levels of the predictor.

ylim

Y axis limits for activity plot.

L

The length of the time points.

xlab

The label for the x-axis.

ylab

The label for the y-axis.

Value

One plot of the estimated group means and a possible second plot of the F-test results.

Examples

Run this code
# NOT RUN {
	data(act_29pt)
	data(clinic_29pt_ahi)
	
	data <- act_29pt
	ahi <- clinic_29pt_ahi
	
	ahi$ahicat <- as.factor(ifelse(ahi$AHI >= 0 & ahi$AHI <= 5, 1, 
					ifelse(ahi$AHI > 5 & ahi$AHI <= 15, 2,
					ifelse(ahi$AHI > 15 & ahi$AHI <= 30, 3,
					ifelse(ahi$AHI > 30, 4, 0)))))
	
	matchidb <- fda.matchid(data, ahi[,-2] , "factor", 
			c("normal", "mild", "moderate", "severe"))
	FDcatahi <- fda.smoothdata(matchidb)
	
	L <- nrow(data)
	lb <- c("Midnight", "6AM", "Noon", "6PM", "Midnight") 
	xat <- c(0, L/4, L/2, 3*L/4, L)
	
	geftFDcatahi <- flm_cate(FDcatahi)
	predy <- as.vector(geftFDcatahi$freg$yhatfdobj$y)
	
	xlim <- c(0, L) 
	ylim <- c(min(predy), max(predy) + 100)
	
	cat.flm.results <- cat_flm_plot(FDcatahi, matchidb, geftFDcatahi, 
			TRUE, 5, lb, xat, "AHI", 1:4, ylim, L)
# }

Run the code above in your browser using DataLab