SimRPrInDT {PrInDT} | R Documentation |
Interdependent estimation for regression
Description
The function SimRPrInDT applies structured subsampling for finding an optimal subsample to model
the relationship between the continuous variables with indices 'inddep' and all other factor and numerical variables
in the data frame 'datain'.
The substructure of the observations used for subsampling is specified by the list 'Struc' which consists of the 'name' of the variable representing the substructure,
the name 'check' of the variable with the information about the categories of the substructure, and the matrix 'labs' which specifies the values of 'check'
corresponding to two categories in its rows, i.e. in 'labs[1,]' and 'labs[2,]'. The names of the categories have to be specified by rownames(labs)
.
In structured subsampling first 'M' repetitions of subsampling of the variable 'name' with 'nsub' different elements of the substructure are realized. If 'nsub' is a list, each entry is employed individually. Then,
for each of the subsamples 'N' repetitions of subsampling of 'ppre' percentages of the predictors are carried out.
Subsampling of observations can additionally be restricted to 'pobs' percentages.
The optimization citerion is the goodness of fit R2 on the full sample. At stage 2, the models are optimized individually.
At stage 3, the mean of accuracies is optimized over all models.
The trees generated from undersampling can be restricted by not accepting trees
including split results specified in the character strings of the vector 'ctestv'.
The parameters 'conf.level', 'minsplit', and 'minbucket' can be used to control the size of the trees.
Usage
SimRPrInDT(data,ctestv=NA,Struc,inddep,N=99,pobs=0.9,ppre=c(0.9,0.7),
M,nsub,conf.level=0.95,minsplit=NA,minbucket=NA)
Arguments
data |
Input data frame with continuous target variables with column indices 'inddep' and the |
ctestv |
Vector of character strings of forbidden split results; |
Struc |
= list(name,check,labs), cf. description for explanations |
inddep |
Column indices of target variables in datain |
N |
Number of repetitions of subsampling (integer) of predictors; default = 99 |
pobs |
Percentage(s) of observations for subsampling; default=0.9 |
ppre |
Percentage(s) of predictors for subsampling; default=c(0.9,0.7) |
M |
Number of repetitions of subsampling of elements of substructure |
nsub |
(List of) numbers of different elements of substructure per subsample |
conf.level |
(1 - significance level) in function |
minsplit |
Minimum number of elements in a node to be splitted; |
minbucket |
Minimum number of elements in a node; |
Details
See Buschfeld & Weihs (2025), Optimizing decision trees for the analysis of World Englishes and sociolinguistic data. Cambridge University Press, section 4.5.6.2, for further information.
Standard output can be produced by means of print(name)
or just name
as well as plot(name
where 'name' is the output data
frame of the function.
Value
- modelsF
Best trees at stage 1
- modelsI
Best trees for the different values of 'nsub' at stage 2
- modelsJ
Best trees for the different values of 'nsub' after mean optimization
- depnames
names of dependent variables
- R2All
R2s of best trees at stages 1, 2, mean max.
Examples
data <- PrInDT::data_vowel
data <- na.omit(data)
CHILDvowel <- data$Nickname
data$Nickname <- NULL
syllable <- 3 - data$syllables
data$syllabels <- NULL
data$syllables <- syllable
data$speed <- data$word_duration / data$syllables
names(data)[names(data) == "target"] <- "vowel_length"
# interpretation restrictions (split exclusions)
ctestv <- rbind('ETH == {C2a, C1a}','MLU == {1, 3}') # split exclusions
# structure definition
name <- CHILDvowel
check <- "data$ETH"
labs <- matrix(1:6,nrow=2,ncol=3)
labs[1,] <- c("C1a","C1b","C1c")
labs[2,] <- c("C2a","C2b","C2c")
rownames(labs) <- c("children 1","children 2")
Struc <- list(name=name,check=check,labs=labs)
# column indices of dependent variables
inddep <- c(13,9)
outSimR <- SimRPrInDT(data,ctestv=ctestv,Struc=Struc,inddep=inddep,N=3,M=2,
nsub=c(19,20),conf.level=0.99)
outSimR
plot(outSimR)