Question

Use R to tackle the problem

Write a function which takes as input x = (x1, . . . , xn) and y = (y1, . . . , yn) and outputs the slope and intercept given by the method of least squares.

Answer #1

The first thing to do is to specify the data. Here x is the explanatory variable and y is the response variable.

> x<-c(x_{1},x_{2},....,x_{n}) > y<-c(y_{1},y_{2},....,y_{n})

Input the values instead of x_{1},x_{2},....,x_{n }and y_{1},y_{2},....,y_{n}

Next is to check for the linearity of the data by constructing a scatter plot and measuring the correlation coefficient.The output will be correlation coefficient. Least square regression can be performed only if there is linearity for that the value of correlation coefficient must be high in magnitude ie between -1 and -0.7 or 0.7 and 1 > plot(x,y) > cor(x,y)

Next is to fit a linear regression with the method of least squares. The command used here is lm Use help(lm) command to learn more.

> fit<-lm(rate~year) > fit

lm command will give you two things the slope and the intercept. eg The figure below x is the slope.

Coefficients: (Intercept) x 420.208 0.5301

Feel free to contact incase of doubts, thankyou

In R- Studio : Write a function that takes as an input a
positive integer and uses the print() function to print out all the
numbers less than the input integer. (Example: for input 5, the
function should print the numbers 1,2,3,4 { for input 1, the
function should not print a number.) Write a recursive function, do
not use any of the loop commands in your code.

N particles can move in plane (x,y).
Write down coordinates and momenta of all particles forming the
phase space and determine number of degrees of freedom
s.
(a) x1, px1,
y1, py1,
x2, px2,
y2, py2,…,
xN, pxN,
yN, pyN ,
s=2N
(b) x1, px1,
x2, px2, …,
xN, pxN ,
s=2N
(c) y1, py1,
y2, py2,…,
yN, pyN ,
s=2N
(d) x1, y1,
x2, y2, …,
xN, yN ,
s=2N
and why you choose

Complete the following question in R.
Problem 5. Write a function in R called like which takes an
input vector dat, assumed to be Poisson random variates, and
computes the Maximum-Likelihood Estimator for λ

Write a function find square root(x) that takes as input a
number x and as output returns the square root of x. Your results
should converge to at least 6 decimal places. matlab question

Write an R function that takes three input values which would be
three coefficients,
solves quadratic equations, and prints both roots.
If the roots are the same, print the root only once. # If there
are no real roots, print the message "There are no real roots."
For information of the quadratic equations, here is the Wiki
page link
https://en.wikipedia.org/wiki/Quadratic_equation
Your code below
Then call the function you've just created and input the
coefficients for
the equations 3x^2 +5x +...

Use R to tackle the following problem
Suppose there is a class of 23 people with birthdays given by
the random variables X1, . . . , X23. Suppose that the random
variables are independent and that each Xi has the property that
P(Xi = k) = 1 365 for 1 ≤ k ≤ 365; thus we make the assumption that
there are no leap years and that people are equally likely to be
born on each day of the...

Write an OCaml function named is_square that takes as input an
integer, say n, (which may be positive or negative) and returns
true if that number is square. That is, it returns true if there
exists an an integer, say m, if m * m = n.
Next, write a function named count_squares that calls count from
above to determine the number of squares in a list of integers. For
example,
count_squares [2;3;5] = 0
count_squares [1;2;3;4;5;6;7;8;9] = 3

Write a function in Matlab that takes as input the number of
iterations k, the size n, and a sparse matrix A. Have this function
run the Power method for k iterations on an initial guess the
vector of 1’s and output the dominant eigenvalue and its
corresponding eigenvector. Use only basic programming.
Write out or print out your function.

3. Write function, leastChar(inputString) that takes as input a
string of one or more letters (and no other characters) and prints
1) the "least" character in the string, where one character is less
than another if it occurs earlier in the alphabet (thus 'a' is less
than 'C' and both are less than 'y') and 2) the index of the first
occurrence of that character. When comparing letters in this
problem, ignore case - i.e. 'e' and 'E' should be...

Write a function
called TaylorSin.m that takes as input an array x, and positive
integer N, and returns the Nth Taylor polynomial approximation of
sin(x), centered at a = 0. The first line of your code should
read
function s =
TaylorSin(x,N)
HINT: in computing k!,
use kfact = k*(k-1)*kfact since you are counting by 2

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 3 minutes ago

asked 5 minutes ago

asked 14 minutes ago

asked 59 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 2 hours ago

asked 2 hours ago

asked 2 hours ago

asked 2 hours ago