Ggplot কীভাবে আবেগগুলির জন্য আত্মবিশ্বাসের গতি গণনা করে?


15

আর প্লটিং প্যাকেজ ggplot2 এর সাথে যুক্ত আত্মবিশ্বাস ব্যান্ডের সাথে রিগ্রেশন লাইন (বা কার্ভ) প্লট করার জন্য স্ট্যাট_স্মোথ নামে একটি দুর্দান্ত কাজ রয়েছে।

তবে প্রতিবারের রেগ্রেশন লাইনের (বা "পদ্ধতি") জন্য এই আত্মবিশ্বাস ব্যান্ডটি কীভাবে উত্পন্ন হয় ঠিক তা নির্ণয় করতে আমার খুব কষ্ট হচ্ছে। আমি এই তথ্যটি কীভাবে খুঁজে পাব?


2
আপনার লিঙ্কে "বিশদ" শিরোনামে বিভাগটি দেখুন।
স্টাফেন লরেন্ট

1
@StéphaneLaurent : I have read that section, but I still have trouble connecting the dots. I use the "rlm" method for fitting a line, how is the confidence interval computed (mathematically, what equation/algorithm?) ? How can I find that information?
static_rtti

1
So I think you should ask a more precise question.
Stéphane Laurent

1
I think your question is reasonably precise... but I suspect you will not get an answer here. You may have better luck at the ggplot2 google group: groups.google.com/forum/?fromgroups#!forum/ggplot2
russellpierce

উত্তর:


22

From the Details section of the help

Calculation is performed by the (currently undocumented) predictdf generic function and its methods. For most methods the confidence bounds are computed using the predict method - the exceptions are loess which uses a t-based approximation, and for glm where the normal confidence interval is constructed on the link scale, and then back-transformed to the response scale.

So predictdf will generally call stats::predict, which in turn will call the correct predict method for the smoothing method. Other functions involving stat_smooth are also useful to consider.

Most model fitting functions will have predict method associated with the class of the model. These will usually take a newdata object and an argument se.fit that will denote whether the standard errors will be fitted. (see ?predict) for further details.

se
display confidence interval around smooth? (TRUE by default, see level to control

This is passed directy to the predict method to return the appropriate standard errors (method dependant)

fullrange
should the fit span the full range of the plot, or just the data

This defines the newdata values for x at which the predictions will be evaluated

level level of confidence interval to use (0.95 by default)

Passed directly to the predict method so that the confidence interval can define the appropriate critical value (eg predict.lm uses qt((1 - level)/2, df) for the standard errors to be multiplied by

n number of points to evaluate smoother at

Used in conjunction with fullrange to define the x values in the newdata object.

Within a call to stat_smooth you can define se which is what is partially matched to se.fit (or se), and will define the interval argument if necessary. level will give level of the confidence interval (defaults 0.95).

The newdata object is defined within the processing, depending on your setting of fullrange to a sequence of length n within the full range of the plot or the data.

In your case, using rlm, this will use predict.rlm, which is defined as

predict.rlm <- function (object, newdata = NULL, scale = NULL, ...)
{
    ## problems with using predict.lm are the scale and
    ## the QR decomp which has been done on down-weighted values.
    object$qr <- qr(sqrt(object$weights) * object$x)
        predict.lm(object, newdata = newdata, scale = object$s, ...)
}

So it is internally calling predict.lm with an appropriate scaling of the qr decomposition and scale argument.


... and predict.rlm is hidden inside MASS ... and the call to predictdf passes model, xseq, se, and level arguments to predict.rlm... but where did those values come from? Well, I guess that depends on what happens when arguments are passed from stat_smooth to StatSmooth$new ... which then in turn calls ...
russellpierce

1
My point being, that your answer is a step in the right direction, but answering OPs question entirely is not as trivial as it first seems (although one expects the code will behave sensibly... one isn't sure unless one traces it fully)
russellpierce

2
One does expect the code to behave sensibly, if the predict method has been set up in a standard way. I've edited my answer to to address the issues raised in your first comment.
mnel

@mnel: many thanks for this very detailed and useful answer!
static_rtti
আমাদের সাইট ব্যবহার করে, আপনি স্বীকার করেছেন যে আপনি আমাদের কুকি নীতি এবং গোপনীয়তা নীতিটি পড়েছেন এবং বুঝতে পেরেছেন ।
Licensed under cc by-sa 3.0 with attribution required.