Skip to content

R Frequently Asked Questions

Statistical Computing and Graphics in R

Menu
  • Learn R
    • R Basics
      • R FAQS about Package
      • R GUI
      • Using R packages
      • Missing Values
    • R Graphics
    • Data Structure
      • Data Frame
      • Matrices
      • List
    • R Programming
    • Statistical Models
  • R Quiz
    • MCQs R Programming
    • R Basic Quiz 7
    • MCQs R Debugging 6
    • MCQs R Vectors 5
    • R History & Basics 4
    • R Language Test 3
    • R Language MCQs 2
    • R Language MCQs 1
  • MCQs
    • MCQs Statistics
      • MCQs Basic Statistics
      • MCQs Probability
      • MCQs Graph & Charts
      • MCQs Sampling
      • MCQs Inference
      • MCQs Correlation & Regression
      • MCQs Time Series
      • MCQs Index Numbers
      • MCQs Quality Control 1
    • MCQS Computer
    • MCQs Mathematics Part-I
  • About ME
  • Contact Us
  • Glossary

Tag: Fomulae in R

Statistical Models in R Language

No Comments
| Statistical Models

R language provides an interlocking suite of facilities that make fitting statistical models very simple. The output from statistical models in R language is minimal and one needs to ask for the details by calling extractor functions.

Defining Statistical Models; Formulae in R Language

The template for a statistical model is a linear regression model with independent, heteroscedastic errors, that is
$latex \sum_{j=0}^p \beta_j x_{ij}+ e_i, \quad e_i \sim NID(0, \sigma^2), \quad i=1,2,\dots, n, j=1,2,\cdots, p$

In matrix form, statistical model can be written as
$latex y=X\beta+e$,
where the $latex y$ is the dependent (response) variable, $latex X$ is the model matrix or design matrix (matrix of regressors) and has columns $latex x_0, x_1, \cdots, x_p$, the determining variables with intercept term. Usually $latex x_0$ is a column of ones defining an intercept term in statistical model.

Statistical Model Examples
Suppose $latex y, x, x_0, x_1, x_2, \cdots$ are numeric variables, $latex X$ is a matrix. Following are some examples that specify statistical models in R.

  • y ~ x    or   y ~ 1 + x
    Both examples imply the same simple linear regression model of $latex y$ on $latex x$. The first formulae has an implicit intercept term and the second formulae has an explicit intercept term.
  • y ~ 0 + x  or  y ~ -1 + x  or y ~ x – 1
    All these imply the same simple linear regression model of $latex y$ on $latex x$ through the origin, that is, without an intercept term.
  • log(y) ~ x1 + x2
    Imply multiple regression of the transformed variable, $latex(log(y)$ on $latex x_1$ and $latex x_2$ with an implicit intercept term.
  • y ~ poly(x , 2)  or  y ~ 1 + x + I(x, 2)
    Imply a polynomial regression model of $latex$ y on $ latex x$ of degree 2 (second degree polynomials) and the second formulae uses explicit powers as basis.
  • y~ X + poly(x, 2)
    Multiple regression $latex y$ with model matrix consisting of the design matrix $latex X$ as well as polynomial terms in $latex x$ to degree 2.

Note that the operator ~ is used to define a model formula in R language. The form of an ordinary linear regression model is, $latex response\,\, ~ \,\, op_1\,\, term_1\,\, op_2\,\, term_2\,\, op_3\,\, term_3\,\, \cdots $,

where

The response is a vector or matrix defining the response (dependent) variable(s).
$latex op_i$ is an operator, either + or -, implying the inclusion or exclusion of a term in the model. The + operator is optional.
$latex term_i$ is either a matrix or vector or 1. It may be a factor or a formula expression consisting of factors, vectors or matrices connected by formula operators.

Share this:

  • Twitter
  • Facebook
  • LinkedIn
  • Skype
  • Tumblr
  • Pinterest
  • Print
  • WhatsApp
  • Telegram
  • Reddit
  • Pocket

Like this:

Like Loading...

Read More »

Subscribe via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 265 other subscribers

Search Form

Facebook

Facebook

Categories

  • Advance R Programming (3)
  • Data Analysis (12)
    • Comparisons Tests (2)
    • Statistical Models (10)
  • Data Structure (9)
    • Data Frame (2)
    • Factors in R (1)
    • List (2)
    • Matrices (2)
    • Vectors in R (1)
  • Importing/ Exporting Data (4)
    • R Data Library (4)
  • R Control Structure (3)
    • For loop in R (1)
    • Switch Statement (1)
  • R FAQS (18)
    • Missing Values (2)
    • R Basics (12)
    • R FAQS about Package (3)
    • R Programming (2)
  • R Graphics (4)
    • Exploring Data in R (1)
    • plot Function (2)
  • R Language Basics (4)
  • R Language Quiz (8)
  • Using R packages (2)
https://www.youtube.com/watch?v=MZpiMyAfnYQ&list=PLB01qg3XnNiMbKkvP2wYzzHkv6ZekaKZx

Posts: itfeature.com: Basic Statistics and Data Analysis

MCQs Chi-Square Association 2

The relationship/ Dependency (also called Association) between the attributes is called relationship/association and the measure of degrees of relationship between the attributes is called the coefficient of association. The Chi-Square Statistic is used to…

Short Questions Sampling and Sampling Distributions 1

The post is about some important Short Questions about sampling and sampling distribution. Q1: Define Sample and Sampling. Answer: Sample: A small portion of the population representing the qualities of the population being sampled…

MCQs IBM SPSS-1

Online MCQs about IBM SPSS with answers.

MCQs Correlation and Regression 6

This Quiz contains MCQs about Correlation and Regression Analysis, Multiple Regression Analysis, Coefficient of Determination (Explained Variation), Unexplained Variation, Model Selection Criteria, Model Assumptions, Interpretation of results, Intercept, Slope, Partial Correlation, Significance tests, OLS Assumptions,…

Short Questions: Normal and Standard Normal Distribution

The following post is about Short Questions related to Normal and Standard Normal Distribution. Q1: What is a standard normal variable? Ans: The variable $Z=\frac{X-\mu}{\sigma}$ which measures the deviations of variable $X$ from the…

Posts: gmstat.com: GM Statistics

MCQs Number System – 4

MCQs Economics – 3

MCQs Economics – 2

Try MCQs Economics Test 1

MCQs Economics – 1

MCQs Econometrics Quiz 5

This quiz is about Econometrics, which covers the topics of Regression analysis, correlation, dummy variable, multicollinearity, heteroscedasticity, autocorrelation, and many other topics. Let’s start with MCQs Econometrics test An application of different statistical methods applied to the economic data used…

R Frequently Asked Questions 2023 . Powered by WordPress

%d bloggers like this:
    pixel