How to calculate Total least squares in R? (Orthogonal regression) [closed] - r

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I didn't find a function to calculate the orthogonal regression (TLS - Total Least Squares).
Is there a package with this kind of function?
Update: I mean calculate the distance of each point symmetrically and not asymmetrically as lm() does.

You might want to consider the Deming() function in package MethComp [function info]. The package also contains a detailed derivation of the theory behind Deming regression.
The following search of the R Archives also provide plenty of options:
Total Least Squares
Deming regression
Your multiple questions on CrossValidated, here and R-Help imply that you need to do a bit more work to describe exactly what you want to do, as the terms "Total least squares" and "orthogonal regression" carry some degree of ambiguity about the actual technique wanted.

Two answers:
gx.rma in the rgr package appears to do this.
Brian Ripley has given a succinct answer on this thread. Basically, you're looking for PCA, and he suggests princomp. I do, too.

I got the following solution from this url:
https://www.inkling.com/read/r-cookbook-paul-teetor-1st/chapter-13/recipe-13-5
r <- prcomp( ~ x + y )
slope <- r$rotation[2,1] / r$rotation[1,1]
intercept <- r$center[2] - slope*r$center[1]
Basically you performa PCA that will fit a line between x and y minimizing the orthogonal residuals. Then you can retrieve the intercept and slope for the first component.

For anyone coming across this question again, there exists a dedicated package 'onls' by now for that purpose. It is similar handled as the nls package (which implements ordinary least square algorithms)

Related

Any R implementation for dimension reduction using random projection? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I have a large p (~20K) and small n (~500) problem. The first thing I was thinking is dimension reduction. After trying PCA, robust PCA, ICA, removing highly correlated features, I was thinking to use Random Projection. However, there is no simple R implementation of Random Projection.
I have found a few random projection R packages, like
MCLUST: https://cran.r-project.org/web/packages/mclust/index.html
RPEnsemble: https://cran.r-project.org/web/packages/RPEnsemble/index.html
But, it seems that they don't support random projection directly for dimension reduction. I have limited knowledge about random projection, but I found two functions in sklearn support this:
Gaussian random projection and Sparse random projection:
http://scikit-learn.org/stable/modules/random_projection.html
And it has pretty simple function interface.
Is that possible to implement random projection easily in R? Or, taking advantage of existing tools to do dimension reduction with Random Projection in R?
I concur that the RPEnsemble package doesn't seem to expose the low-level methods that would allow you to use only that feature in any convenient form.
I did however come across this R source code which seems fairly straight-forward and reasonably documented: R source code for random projections. This is part of the clusterv package and you can download it there.

How to create a mathematical function from data plots [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I am by no means a math person, but I am really trying to figure out how create a graphable function from some data plots I measure from a chemical titration. I have been trying to learn R and I would like to know if anyone can explain to me or point me to a guide to create a mathmatic function of the titration graph below.
Thanks in advance.
What you are looking for is a Interpolation. I'm not a R programmer, but I'll try to answer anyway.
Some of the more common ways to achieve this function you want is by Polynomial Interpolation which usually gives back a Nth degree polynomial function, where N is the number of data points minus one (1 point gives a constant, 2 points make a line, 3 makes a*x^2 + b*x + c and so on).
Other common alternatives I've learn are used in Computer Graphics are Splines, B-spline, Bézier curve and Hermite interpolation. Those make the curve smoother and good looking (I've told they originated in the car industry so they are less true to the data points).
TL;DR: I've found evidence that there is a implementation of spline in R from the question Interpolation in R which may lead you to your solution.
Hope you get to know better your tool and do a great work.
When doing this kind of work in Computer Science we call it Numerical Methods (at least here in my university), I've done some class and homework in this area while attending to the Numerical Methods Course (it can be found at github) but it's nothing worth noting.
I would add a lot of links to Wikipedia but StackOverflow didn't allow it.

How can I use R to get confidence intervals in Azure ML? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I came across this question which asks if Azure ML can calculate confidence - or probabilities - for row data prediction. However, given that the answer to that question is No, and suggests to use R, I am trying to figure out how to use R to do exactly this for a regression model.
Does anyone have any suggestions for references on where to look for this?
My scenario is that I have used Azure ML to build a boosted decision tree regression model, which outputs a Scored Label column. But I don't know regression analysis well enough to write R code to use the outputted model to get confidence intervals.
I am looking for any references that can help me understand how to do this in R (in conjuncture with Azure ML).
There isn't a straight forward way to compute the confidence interval from the results of the Boosted Decision Tree model in Azure ML.
Here are some alternate suggestions:
Rebuild the model using the library(gbm) http://artax.karlin.mff.cuni.cz/r-help/library/gbm/html/gbm.html or the library(glm) https://stat.ethz.ch/R-manual/R-devel/library/stats/html/glm.html
Then build the confidence interval using confint function: https://stat.ethz.ch/R-manual/R-devel/library/stats/html/confint.html
For a linear model, the confidence interval computation is simpler: http://www.r-tutor.com/elementary-statistics/simple-linear-regression/confidence-interval-linear-regression

spline approximation with specified number of intervals [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
So - edited because some of us thought that this question is off-topic.
I need to build spline (approximation) on 100 points in one of environments listed in tags. But I need it with exact number of intervals (maximum of 6 intervals - separate equations - in whole domain). Packages / libraries in R and Maxima which I know let me for building spline on this points but with 25-30 intervals (separate equations). Does anyone know how to build spline with set number of intervals without coding whole algorithm all over again?
What you're looking for might be described as "local regression" or "localized regression"; searching for those terms might turn up some hits.
I don't know if you can find exactly what you've described. But implementing it doesn't seem too complicated: (1) Split the domain into N intervals (say N=10). For each interval, (2) make a list of the data in the interval, (3) fit a low-order polynomial (e.g. cubic) to the data in the interval using least squares.
If that sounds interesting to you, I can go into details, or maybe you can work it out yourself.

How can I calculate predictor coefficients in linear prediction model in R? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I'm quite new to R and I have the following problem:
I have a time series / signal and I want to build linear prediction model. It seems something like Matlab lpc will be great but I can't find corresponding function in R. Which package should I use?
It seems like you're talking about an autoregressive (AR) model - Yule-Walker equations seem to be at the heart of what you linked to. In which case, the ar function in the basic R installation may suffice or for more complicated models the arima function, also in the basic installation.
You should also look at the Time Series Task View on CRAN for additional information on suitable packages and I recommend you consult it for further options.
The kind of analysis you are trying to to can be done using packages in the timeseries task view. Most likely you want some kind of Autoregressive model (AR), for which I refer to the Forecasting and Univariate Modeling section of that task view. The linear filtering method you mentioned is probably implemented in packages like robfilter, more info can be found in the Decomposition and Filtering section of the task view.

Resources