Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to understand yearly in formula in R language. And the meaning of y~x:z

Shulou Source: shulou.com Published: 2022-06-01 22:24:37 10月01日 Update

This article will explain in detail how to understand y~. And y~x:z meaning, the content of the article is of high quality, so Xiaobian share for everyone to make a reference, I hope you have a certain understanding of relevant knowledge after reading this article.

01 How to understand y~. What is the meaning of y~x:z?

y~. and y~x:z is a simple formula. ~ and: are operators in formula, but they are somewhat different from commonly understood mathematical operators.

The "~" symbol in formula associates the response variable (on the left side of ~) with the explanatory variable (on the right side of ~) of the model. It is commonly used in linear/general linear models (e.g. lm(),glm()), tree methods (e.g. rpart()), graphical representations (e.g. coplot()), and other situations (e.g. table()).

Here are the meanings of some of the other operators in formula:

~:~ connects the two sides of the formula, the left side of ~ is the dependent variable, and the right side is the independent variable.

+ : Different items in the model are separated by +. Note that the default expression in R has constant terms, so it is estimated that you only need to write y~x.

- : -indicates removal of a term from the model, y~x-1 indicates removal of a constant term from the model, and estimates a regression equation that crosses the origin without an intercept term. Besides, y~x+0 or y~0+x can also represent regression equation without intercept term.

:: Colons indicate interaction terms in formulas

* : * does not indicate multiplication,

^:^2 does not mean square in formula

What if you want to add mathematical operators to an expression? For the logarithm of a variable, you can write log(y)~log(x) directly, which means estimation; the natural exponent can also be expressed directly as exp(); but if you want to express addition, subtraction, multiplication, division and square, you need to use the operator I(). What is the difference between y~x+w+z and y~x+I(w+z)? If you want to estimate a dynamic panel model, in the plm packet, the lagged variable is represented by the operator lag(), e.g. lag(x,1) represents a lagged variable with one lag in x, lag(log(z), 2) represents a lagged variable with two lags in log(z), and the difference term is represented by the operator diff(). How to understand y~. in formula in R language The meaning of y~x:z is shared here. I hope the above content can be of some help to everyone and learn more knowledge. If you think the article is good, you can share it so that more people can see it.

Tags: Operators operations variables models meanings languages expressions formulas content right constants mathematics articles equations more knowledge articles linear different good Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Xiaomi Shulou Information OPPO Reno MariaDB