psychotree: Interfaces for psychotree package for data science pipelines.

Description Usage Arguments Details Value Author(s) Examples

Description

Interfaces to psychotree functions that can be used in a pipeline implemented by magrittr.

Usage

1
2
3
4
5

Arguments

data

data frame, tibble, list, ...

...

Other arguments passed to the corresponding interfaced function.

Details

Interfaces call their corresponding interfaced function.

Value

Object returned by interfaced function.

Author(s)

Roberto Bertolusso

Examples

  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
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
## Not run: 
library(intubate)
library(magrittr)
library(psychotree)


## ntbt_bttree: Bradley-Terry Tree Models
data("Topmodel2007", package = "psychotree")

## Original function to interface
tm_tree <- bttree(preference ~ ., data = Topmodel2007,
                  minsize = 5, ref = "Barbara")
plot(tm_tree, abbreviate = 1, yscale = c(0, 0.5))

## The interface puts data as first parameter
tm_tree <- ntbt_bttree(Topmodel2007, preference ~ .,
                       minsize = 5, ref = "Barbara")
plot(tm_tree, abbreviate = 1, yscale = c(0, 0.5))

## so it can be used easily in a pipeline.
Topmodel2007 %>%
  ntbt_bttree(preference ~ ., minsize = 5, ref = "Barbara") %>%
  plot(abbreviate = 1, yscale = c(0, 0.5))



## ntbt_mpttree: MPT Tree Models
data("SourceMonitoring", package="psychotools")

## Original function to interface
sm_tree <- mpttree(y ~ sources + gender + age, data = SourceMonitoring,
                   spec = mptspec("SourceMon", .restr = list(d1 = d, d2 = d)))
plot(sm_tree, index = c("D1", "D2", "d", "b", "g"))

## The interface puts data as first parameter
sm_tree <- ntbt_mpttree(SourceMonitoring, y ~ sources + gender + age,
                        spec = mptspec("SourceMon", .restr = list(d1 = d, d2 = d)))
plot(sm_tree, index = c("D1", "D2", "d", "b", "g"))

## so it can be used easily in a pipeline.
SourceMonitoring %>%
  ntbt_mpttree(y ~ sources + gender + age,
               spec = mptspec("SourceMon", .restr = list(d1 = d, d2 = d))) %>%
  plot(index = c("D1", "D2", "d", "b", "g"))



## ntbt_pctree: Partial Credit Tree Models
data("VerbalAggression", package = "psychotools")
VerbalAggression$s2 <- VerbalAggression$resp[, 7:12]
VerbalAggression <- subset(VerbalAggression, rowSums(s2) > 0 & rowSums(s2) < 12)

## Original function to interface
pct <- pctree(s2 ~ anger + gender, data = VerbalAggression)
plot(pct, type = "profile")

## The interface puts data as first parameter
pct <- ntbt_pctree(VerbalAggression, s2 ~ anger + gender)
plot(pct, type = "profile")

## so it can be used easily in a pipeline.
VerbalAggression %>%
  ntbt_pctree(s2 ~ anger + gender) %>%
  plot(type = "profile")



## ntbt_raschtree: Rasch Tree Models
data("DIFSim", package = "psychotree")

## Original function to interface
rt <- raschtree(resp ~ age + gender + motivation, data = DIFSim)
plot(rt)

## The interface puts data as first parameter
rt <- ntbt_raschtree(DIFSim, resp ~ age + gender + motivation)
plot(rt)

## so it can be used easily in a pipeline.
DIFSim %>%
  ntbt_raschtree(resp ~ age + gender + motivation) %>%
  plot()



## ntbt_rstree: Rating Scale Tree Models
data("VerbalAggression", package = "psychotools")
VerbalAggression$s1 <- VerbalAggression$resp[, 1:6]
VerbalAggression <- subset(VerbalAggression, rowSums(s1) > 0 & rowSums(s1) < 12)

## Original function to interface
rst <- rstree(s1 ~ anger + gender, data = VerbalAggression)
plot(rst, type = "profile")

## The interface puts data as first parameter
rst <- ntbt_rstree(VerbalAggression, s1 ~ anger + gender)
plot(rst, type = "profile")

## so it can be used easily in a pipeline.
VerbalAggression %>%
  ntbt_rstree(s1 ~ anger + gender) %>%
  plot(type = "profile")

## End(Not run)

intubate documentation built on May 2, 2019, 2:46 p.m.