Quality plotting and graphing

1. Advantage

R simplifies quality plotting and graphing. R libraries such as ggplot2 and plotly advocates for visually appealing and aesthetic graphs which set R apart from other programming languages.

October 30, 2024 / 0 Comments
read more

Exemplary support for data wrangling

1. Advantage

R allows us to perform data wrangling. R provides packages such as dplyr, readr which are capable of transforming messy data into a structured form.

October 30, 2024 / 0 Comments
read more

Binomial Distribution

4. Statistics Examples

The binomial distribution model deals with finding the probability of success of an event which has only two possible outcomes in a series of experiments. For example, tossing of a coin always gives a head or a tail. The probability of finding exactly 3 heads in tossing a coin repeatedly for 10 times is estimated during the binomial distribution. R has four in-built functions to generate binomial distribution. They are described below. Following is the description of the parameters used − dbinom() This function gives the probability density distribution at each point. When we execute the above code, it produces the following result − pbinom() This function gives the cumulative probability of an event. It is a single value representing the probability. When we execute the above code, it produces the following result − Explore our latest online courses and learn new skills at your own pace. Enroll and become a certified expert to boost your career. qbinom() This function takes the probability value and gives a number whose cumulative value matches the probability value. When we execute the above code, it produces the following result − rbinom() This function generates required number of random values of given probability from a given sample. When we execute the above code, it produces the following result −

October 30, 2024 / 0 Comments
read more

Machine Learning Operations

1. Advantage

R allows us to do various machine learning operations such as classification and regression. For this purpose, R provides various packages and features for developing the artificial neural network. R is used by the best data scientists in the world.

October 30, 2024 / 0 Comments
read more

Platform Independent

1. Advantage

R is a platform-independent language or cross-platform programming language which means its code can run on all operating systems. R enables programmers to develop software for several competing platforms by writing a program only once. R can run quite easily on Windows, Linux, and Mac.

October 30, 2024 / 0 Comments
read more

Open Source

1. Advantage

An open-source language is a language on which we can work without any need for a license or a fee. R is an open-source language. We can contribute to the development of R by optimizing our packages, developing new ones, and resolving issues.

October 30, 2024 / 0 Comments
read more

Normal Distribution

4. Statistics Examples

In a random collection of data from independent sources, it is generally observed that the distribution of data is normal. Which means, on plotting a graph with the value of the variable in the horizontal axis and the count of the values in the vertical axis we get a bell shape curve. The center of the curve represents the mean of the data set. In the graph, fifty percent of values lie to the left of the mean and the other fifty percent lie to the right of the graph. This is referred as normal distribution in statistics. R has four in built functions to generate normal distribution. They are described below. Following is the description of the parameters used in above functions − dnorm() This function gives height of the probability distribution at each point for a given mean and standard deviation. When we execute the above code, it produces the following result − pnorm() This function gives the probability of a normally distributed random number to be less that the value of a given number. It is also called “Cumulative Distribution Function”. When we execute the above code, it produces the following result − Explore our latest online courses and learn new skills at your own pace. Enroll and become a certified expert to boost your career. qnorm() This function takes the probability value and gives a number whose cumulative value matches the probability value. When we execute the above code, it produces the following result − rnorm() This function is used to generate random numbers whose distribution is normal. It takes the sample size as input and generates that many random numbers. We draw a histogram to show the distribution of the generated numbers. When we execute the above code, it produces the following result −

October 30, 2024 / 0 Comments
read more

Logistic Regression

4. Statistics Examples

The Logistic Regression is a regression model in which the response variable (dependent variable) has categorical values such as True/False or 0/1. It actually measures the probability of a binary response as the value of response variable based on the mathematical equation relating it with the predictor variables. The general mathematical equation for logistic regression is − Following is the description of the parameters used − The function used to create the regression model is the glm() function. Syntax The basic syntax for glm() function in logistic regression is − Following is the description of the parameters used − Example The in-built data set “mtcars” describes different models of a car with their various engine specifications. In “mtcars” data set, the transmission mode (automatic or manual) is described by the column am which is a binary value (0 or 1). We can create a logistic regression model between the columns “am” and 3 other columns – hp, wt and cyl. When we execute the above code, it produces the following result − Create Regression Model We use the glm() function to create the regression model and get its summary for analysis. When we execute the above code, it produces the following result − Conclusion In the summary as the p-value in the last column is more than 0.05 for the variables “cyl” and “hp”, we consider them to be insignificant in contributing to the value of the variable “am”. Only weight (wt) impacts the “am” value in this regression model.

October 29, 2024 / 0 Comments
read more

Multiple Regression

4. Statistics Examples

Multiple regression is an extension of linear regression into relationship between more than two variables. In simple linear relation we have one predictor and one response variable, but in multiple regression we have more than one predictor variable and one response variable. The general mathematical equation for multiple regression is − Following is the description of the parameters used − We create the regression model using the lm() function in R. The model determines the value of the coefficients using the input data. Next we can predict the value of the response variable for a given set of predictor variables using these coefficients. lm() Function This function creates the relationship model between the predictor and the response variable. Syntax The basic syntax for lm() function in multiple regression is − Following is the description of the parameters used − Example Input Data Consider the data set “mtcars” available in the R environment. It gives a comparison between different car models in terms of mileage per gallon (mpg), cylinder displacement(“disp”), horse power(“hp”), weight of the car(“wt”) and some more parameters. The goal of the model is to establish the relationship between “mpg” as a response variable with “disp”,”hp” and “wt” as predictor variables. We create a subset of these variables from the mtcars data set for this purpose. When we execute the above code, it produces the following result − Create Relationship Model & get the Coefficients When we execute the above code, it produces the following result − Create Equation for Regression Model Based on the above intercept and coefficient values, we create the mathematical equation. Apply Equation for predicting New Values We can use the regression equation created above to predict the mileage when a new set of values for displacement, horse power and weight is provided. For a car with disp = 221, hp = 102 and wt = 2.91 the predicted mileage is −

October 29, 2024 / 0 Comments
read more

Linear Regression

4. Statistics Examples

Regression analysis is a very widely used statistical tool to establish a relationship model between two variables. One of these variable is called predictor variable whose value is gathered through experiments. The other variable is called response variable whose value is derived from the predictor variable. In Linear Regression these two variables are related through an equation, where exponent (power) of both these variables is 1. Mathematically a linear relationship represents a straight line when plotted as a graph. A non-linear relationship where the exponent of any variable is not equal to 1 creates a curve. The general mathematical equation for a linear regression is − Following is the description of the parameters used − Steps to Establish a Regression A simple example of regression is predicting weight of a person when his height is known. To do this we need to have the relationship between height and weight of a person. The steps to create the relationship is − Input Data Below is the sample data representing the observations − lm() Function This function creates the relationship model between the predictor and the response variable. Syntax The basic syntax for lm() function in linear regression is − Following is the description of the parameters used − Create Relationship Model & get the Coefficients When we execute the above code, it produces the following result − Get the Summary of the Relationship When we execute the above code, it produces the following result − Explore our latest online courses and learn new skills at your own pace. Enroll and become a certified expert to boost your career. predict() Function Syntax The basic syntax for predict() in linear regression is − Following is the description of the parameters used − Predict the weight of new persons When we execute the above code, it produces the following result − Visualize the Regression Graphically When we execute the above code, it produces the following result −

October 29, 2024 / 0 Comments
read more

Posts pagination

Previous 1 … 83 84 85 … 445 Next