Plot shifted t-distribution with ggplot2Rotating and spacing axis labels in ggplot2What do hjust and vjust do when making a plot using ggplot?Overlaying a normal distribution on a histogramPlot quantiles of distribution in ggplot2 with facetsIs there any “add” parameter (like in graphics::curve) for ggplot2?Illustrate mean and standard deviation in ggplot2 density plotHow to plot a set of rotated densities in ggplot2?Trying to add normal distribution curve to ggplot, and it's not workingggplot - altering the height of each overlapping variable on a density plotHow to plot two distribution curves in a faceted way in R / ggplot2?
Why is an old chain unsafe?
How can the DM most effectively choose 1 out of an odd number of players to be targeted by an attack or effect?
Japan - Plan around max visa duration
Can I make popcorn with any corn?
What Brexit solution does the DUP want?
What defenses are there against being summoned by the Gate spell?
Is it possible to make sharp wind that can cut stuff from afar?
A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?
How does one intimidate enemies without having the capacity for violence?
Why is "Reports" in sentence down without "The"
I’m planning on buying a laser printer but concerned about the life cycle of toner in the machine
Shell script can be run only with sh command
Can a German sentence have two subjects?
What is the offset in a seaplane's hull?
Why are 150k or 200k jobs considered good when there are 300k+ births a month?
The magic money tree problem
Extreme, but not acceptable situation and I can't start the work tomorrow morning
Why has Russell's definition of numbers using equivalence classes been finally abandoned? ( If it has actually been abandoned).
Email Account under attack (really) - anything I can do?
Why don't electron-positron collisions release infinite energy?
Example of a relative pronoun
DOS, create pipe for stdin/stdout of command.com(or 4dos.com) in C or Batch?
Is Social Media Science Fiction?
Why CLRS example on residual networks does not follows its formula?
Plot shifted t-distribution with ggplot2
Rotating and spacing axis labels in ggplot2What do hjust and vjust do when making a plot using ggplot?Overlaying a normal distribution on a histogramPlot quantiles of distribution in ggplot2 with facetsIs there any “add” parameter (like in graphics::curve) for ggplot2?Illustrate mean and standard deviation in ggplot2 density plotHow to plot a set of rotated densities in ggplot2?Trying to add normal distribution curve to ggplot, and it's not workingggplot - altering the height of each overlapping variable on a density plotHow to plot two distribution curves in a faceted way in R / ggplot2?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am trying to plot the density curve of a t-distribution with mean = 3 and df = 1.5 using ggplot2. However it is supposed to be symmetric around 3, so I can not use the noncentrality parameter.
ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
stat_function(fun = dt, args = list(df = 1.5))
Is there a way to simply shift the distribution along the x-axis?
r ggplot2
add a comment |
I am trying to plot the density curve of a t-distribution with mean = 3 and df = 1.5 using ggplot2. However it is supposed to be symmetric around 3, so I can not use the noncentrality parameter.
ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
stat_function(fun = dt, args = list(df = 1.5))
Is there a way to simply shift the distribution along the x-axis?
r ggplot2
add a comment |
I am trying to plot the density curve of a t-distribution with mean = 3 and df = 1.5 using ggplot2. However it is supposed to be symmetric around 3, so I can not use the noncentrality parameter.
ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
stat_function(fun = dt, args = list(df = 1.5))
Is there a way to simply shift the distribution along the x-axis?
r ggplot2
I am trying to plot the density curve of a t-distribution with mean = 3 and df = 1.5 using ggplot2. However it is supposed to be symmetric around 3, so I can not use the noncentrality parameter.
ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
stat_function(fun = dt, args = list(df = 1.5))
Is there a way to simply shift the distribution along the x-axis?
r ggplot2
r ggplot2
asked Feb 3 '17 at 14:23
nhoeftnhoeft
15012
15012
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
you could also make a custom function for your shifted t-distribution:
custom <- function(x) dt(x - 3, 1.5)
ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
stat_function(fun = custom)
add a comment |
A simple solution is to just change the labels instead:
ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
stat_function(fun = dt, args = list(df = 1.5)) +
scale_x_continuous(breaks = c(0, 5, 10), labels = c(3, 8, 13))
add a comment |
There is also a function dt.scaled
in the metRology package, which in addition to the df, lets you specify the mean and scale.
Relevant code:
dt.scaled <- function(x, df, mean = 0, sd = 1, ncp, log = FALSE)
if (!log) stats::dt((x - mean)/sd, df, ncp = ncp, log = FALSE)/sd
else stats::dt((x - mean)/sd, df, ncp = ncp, log = TRUE) - log(sd)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42026421%2fplot-shifted-t-distribution-with-ggplot2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
you could also make a custom function for your shifted t-distribution:
custom <- function(x) dt(x - 3, 1.5)
ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
stat_function(fun = custom)
add a comment |
you could also make a custom function for your shifted t-distribution:
custom <- function(x) dt(x - 3, 1.5)
ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
stat_function(fun = custom)
add a comment |
you could also make a custom function for your shifted t-distribution:
custom <- function(x) dt(x - 3, 1.5)
ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
stat_function(fun = custom)
you could also make a custom function for your shifted t-distribution:
custom <- function(x) dt(x - 3, 1.5)
ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
stat_function(fun = custom)
answered Feb 3 '17 at 14:42
NateNate
6,71512030
6,71512030
add a comment |
add a comment |
A simple solution is to just change the labels instead:
ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
stat_function(fun = dt, args = list(df = 1.5)) +
scale_x_continuous(breaks = c(0, 5, 10), labels = c(3, 8, 13))
add a comment |
A simple solution is to just change the labels instead:
ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
stat_function(fun = dt, args = list(df = 1.5)) +
scale_x_continuous(breaks = c(0, 5, 10), labels = c(3, 8, 13))
add a comment |
A simple solution is to just change the labels instead:
ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
stat_function(fun = dt, args = list(df = 1.5)) +
scale_x_continuous(breaks = c(0, 5, 10), labels = c(3, 8, 13))
A simple solution is to just change the labels instead:
ggplot(data.frame(x = c(-4, 10)), aes(x = x)) +
stat_function(fun = dt, args = list(df = 1.5)) +
scale_x_continuous(breaks = c(0, 5, 10), labels = c(3, 8, 13))
answered Feb 3 '17 at 14:35
AxemanAxeman
19.3k54559
19.3k54559
add a comment |
add a comment |
There is also a function dt.scaled
in the metRology package, which in addition to the df, lets you specify the mean and scale.
Relevant code:
dt.scaled <- function(x, df, mean = 0, sd = 1, ncp, log = FALSE)
if (!log) stats::dt((x - mean)/sd, df, ncp = ncp, log = FALSE)/sd
else stats::dt((x - mean)/sd, df, ncp = ncp, log = TRUE) - log(sd)
add a comment |
There is also a function dt.scaled
in the metRology package, which in addition to the df, lets you specify the mean and scale.
Relevant code:
dt.scaled <- function(x, df, mean = 0, sd = 1, ncp, log = FALSE)
if (!log) stats::dt((x - mean)/sd, df, ncp = ncp, log = FALSE)/sd
else stats::dt((x - mean)/sd, df, ncp = ncp, log = TRUE) - log(sd)
add a comment |
There is also a function dt.scaled
in the metRology package, which in addition to the df, lets you specify the mean and scale.
Relevant code:
dt.scaled <- function(x, df, mean = 0, sd = 1, ncp, log = FALSE)
if (!log) stats::dt((x - mean)/sd, df, ncp = ncp, log = FALSE)/sd
else stats::dt((x - mean)/sd, df, ncp = ncp, log = TRUE) - log(sd)
There is also a function dt.scaled
in the metRology package, which in addition to the df, lets you specify the mean and scale.
Relevant code:
dt.scaled <- function(x, df, mean = 0, sd = 1, ncp, log = FALSE)
if (!log) stats::dt((x - mean)/sd, df, ncp = ncp, log = FALSE)/sd
else stats::dt((x - mean)/sd, df, ncp = ncp, log = TRUE) - log(sd)
answered Mar 9 at 3:37
kwiebelskwiebels
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42026421%2fplot-shifted-t-distribution-with-ggplot2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown