-2
I have a base whose one column has three characteristics (strong, weak and moderate. How do I restrict regression so that the model considers only one of the dimensions?
-2
I have a base whose one column has three characteristics (strong, weak and moderate. How do I restrict regression so that the model considers only one of the dimensions?
0
If I understand you right, dataFrame
as follows:
> df
categoria X Y
1 Fraco 118 30
2 Fraco 484 58
3 Fraco 664 87
4 Fraco 1004 115
5 Fraco 1231 120
6 Fraco 1372 142
7 Fraco 1582 145
8 Moderado 118 33
9 Moderado 484 69
10 Moderado 664 111
11 Moderado 1004 156
12 Moderado 1231 172
13 Moderado 1372 203
14 Moderado 1582 203
15 Forte 118 30
16 Forte 484 51
17 Forte 664 75
18 Forte 1004 108
19 Forte 1231 115
20 Forte 1372 139
21 Forte 1582 140
So, to apply a regression model to only one category, you just filter the data. For this we have a few options.
1st: filtering the data directly in the model
lm(X~Y, df[df[1] == "Fraco",])
Here I made it df
to show only observations in column 1 that are equal to weak.
2nd: Filtering the dataframe with Dplyr
#Carrega o pacote dplyr
library(dplyr)
#filtra a categoria de interesse
df %>% filter(categoria == "Fraco") -> df_fraco
#ajusta o modelo
lm(X~Y, df_fraco)
I hope I’ve helped.
Browser other questions tagged r
You are not signed in. Login or sign up in order to post.
What you mean by "putting a restriction in regression". In regression we do not add restrictions, but variables. What is a dimension? Please edit the question with the answers.
– Guilherme Parreira
Maybe
lm(formula, data = subset(base, característica == "forte"))
?– Rui Barradas