-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibrary.R
More file actions
59 lines (50 loc) · 1.66 KB
/
library.R
File metadata and controls
59 lines (50 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#packages we need for building a package
packages <- c("devtools", "ltm", "eRm")
if (length(setdiff(packages, rownames(installed.packages()))) > 0) {
install.packages(setdiff(packages, rownames(installed.packages())))
}
devtools::install_github("klutometis/roxygen")
library("devtools")
library(roxygen2)
library("eRm")
library("ltm")
#create package directory
setwd("parent_directory")
create("cats")
exampleOne_function <- function(){
res.rasch <- RM(raschdat1)
pres.rasch <- person.parameter(res.rasch)
plotPImap(res.rasch, sorted = TRUE)
lrres.rasch <- LRtest(res.rasch, splitcr = "mean")
return(lrres.rasch)
}
exampleTwo_function <- function(){
res.lltm <- LLTM(lltmdat2, W)
summary <- summary(res.lltm)
return(summary)
}
exampleThree_function <- function(){
data(pcmdat2)
res.rsm <- RSM(pcmdat2)
thresholds(res.rsm)
plotICC(res.rsm, mplot = TRUE, legpos = FALSE, ask = FALSE)
res.pcm <- PCM(pcmdat2)
plotPImap(res.pcm, sorted = TRUE)
pres.pcm <- person.parameter(res.pcm)
itemfit(pres.pcm)
lr <- 2 * (res.pcm$loglik - res.rsm$loglik)
df <- res.pcm$npar - res.rsm$npar
pvalue <- 1 - pchisq(lr, df)
cat("LR statistic: ", lr, " df =", df, " p =", pvalue, "\n")
return(res.pcm)
}
exampleFour_function <- function(){
aov_out <- aov(yield ~ N*P, npk)
model.tables(aov_out, "means") # This will give you the means.
model.tables(aov_out, se = TRUE) # Will give you standard errors for the effects.
model.tables(aov_out, "means", se = TRUE) # Will give you the standard error for the differences of means.
return(aov_out)
}
setwd("./cats")
document()
#source: https://hilaryparker.com/2014/04/29/writing-an-r-package-from-scratch/