# =============================================== # Fill in the following fields # =============================================== # Title: # Description: # Author: # Date: #...

1 answer below »
I need to submit this assignment in app.R format coded in language R. The assignment is in the attachments and the outlet of the app.R is attached as well.


# =============================================== # Fill in the following fields # =============================================== # Title: # Description: # Author: # Date: # =============================================== # Required packages # =============================================== library(dplyr) library(ggplot2) # ... # =============================================== # Define UserInterface "ui" for application # =============================================== ui <- fluidpage(="" titlepanel("title="" of="" your="" app"),="" fluidrow(="" #="" inputs="" for="" initial="" amount,="" and="" number="" of="" years="" column(3,="" h4("col1")="" #="" delete="" this="" line="" and="" replace="" it="" with="" your="" widgets!!!="" ),="" #="" inputs="" for="" periodic="" contributions="" column(3,="" h4("col2")="" #="" delete="" this="" line="" and="" replace="" it="" with="" your="" widgets!!!="" ),="" #="" inputs="" for="" avg="" annual="" return,="" and="" avg="" annual="" volatility="" column(3,="" h4("col3")="" #="" delete="" this="" line="" and="" replace="" it="" with="" your="" widgets!!!="" ),="" #="" inputs="" for="" number="" of="" simulations,="" and="" random="" seed="" column(3,="" h4("col4")="" #="" delete="" this="" line="" and="" replace="" it="" with="" your="" widgets!!!="" )="" ),="" hr(),="" h4('dummy="" text="" for="" graph'),="" plotoutput('plot'),="" hr(),="" h4('dummy="" text="" for="" statistics'),="" verbatimtextoutput('table')="" )="" #="==============================================" #="" define="" server="" "server"="" logic="" #="==============================================" server=""><- function(input,="" output)="" {="" #="" you="" may="" need="" to="" create="" reactive="" objects="" #="" (e.g.="" data="" frame="" to="" be="" used="" for="" graphing="" purposes)="" dat=""><- reactive({="" #="" replace="" the="" code="" below="" with="" your="" code!!!="" data.frame(="" mpg="mtcars$mpg," hp="mtcars$hp" )="" })="" #="" code="" for="" graph="" output$plot=""><- renderplot({="" #="" replace="" the="" code="" below="" with="" your="" code!!!="" ggplot(data="dat()," aes(x="HP," y="MPG))" +="" geom_point()="" })="" #="" code="" for="" statistics="" output$table=""><- renderprint({="" #="" replace="" the="" code="" below="" with="" your="" code!!!="" summary(dat())="" })="" }="" #="==============================================" #="" run="" the="" application="" #="==============================================" shinyapp(ui="ui," server="server)" project="" 2:="" investment="" simulator="" shiny="" app="" project="" 2:="" investment="" simulator="" shiny="" app="" stat="" 133,="" spring="" 2021="" motivation="" the="" purpose="" of="" this="" assignment="" is="" to="" create="" an="" investment="" simulator="" using="" a="" shiny="" app.="" you="" will="" have="" to="" create="" a="" shiny="" app,="" publish="" it="" on="" rstudio="" shinyapps.io,="" and="" record="" a="" short="" video—of="" 3="" mins="" max—showing="" how="" your="" app="" works="" and="" how="" to="" make="" sense="" of="" the="" displayed="" information.="" we="" are="" assuming="" that="" you="" have="" gone="" through="" the="" materials="" covered="" in="" weeks="" 7,="" 8,="" and="" 9.="" 1)="" investing="" in="" a="" total="" stock="" market="" index="" fund="" note:="" this="" section="" aims="" to="" provide="" the="" context="" of="" the="" project="" and="" therefore="" is="" purely="" infor-="" mative;="" no="" need="" to="" calculate="" or="" code="" anything="" for="" this="" part.="" we="" are="" going="" to="" consider="" investing="" in="" a="" total="" stock="" market="" index="" fund="" which="" is="" a="" financial="" instrument="" that="" tracks="" the="" performance="" of="" the="" u.s.="" stock="" market.="" this="" type="" of="" instrument="" typically="" takes="" the="" form="" of="" a="" mutual="" fund="" or="" an="" exchange-traded="" fund="" (etf)="" that="" invests="" in="" a="" basket="" of="" stocks="" that="" passively="" tracks="" the="" performance="" of="" the="" u.s.="" stock="" market.="" perhaps="" the="" most="" common="" examples="" of="" these="" funds="" are:="" •="" vanguard="" total="" stock="" market="" index="" fund="" (vtsax)="" •="" fidelity="" total="" market="" index="" fund="" (fskax)="" •="" schwab="" total="" stock="" market="" index="" fund="" (swtsx)="" •="" ishares="" core="" s&p="" total="" u.s.="" stock="" market="" etf="" (itot)="" 1.1)="" investing="" a="" lump-sum="" with="" periodic="" contributions="" say="" you="" are="" going="" to="" start="" your="" investment="" with="" a="" lump-sum="" of="" $1000="" in="" a="" u.s.="" total="" stock="" market="" index="" fund.="" in="" theory,="" this="" is="" money="" that="" you="" don’t="" plan="" to="" use="" within="" the="" next="" 5="" years,="" and="" you="" are="" willing="" to="" invest="" it="" for="" the="" long="" run="" (10="" years="" or="" more).="" also,="" suppose="" you="" decide="" to="" make="" fixed="" periodic="" contributions,="" e.g.="" $30="" at="" the="" end="" of="" each="" month,="" or="" $360="" at="" the="" end="" of="" each="" year.="" how="" much="" money="" would="" you="" expect="" to="" get="" at="" the="" end="" of="" a="" 10-year="" period?="" or="" after="" 15="" years?="" or="" after="" 20="" years?="" or="" after="" a="" longer="" period?="" from="" warmup-4,="" we="" can="" calculate="" the="" future="" value="" and="" interest="" of="" periodic="" contributions="" with="" the="" following="" formula:="" 1="" https://www.thebalance.com/total-stock-market-index-funds-2466402="" https://investor.vanguard.com/mutual-funds/profile/vtsax="" https://fundresearch.fidelity.com/mutual-funds/summary/315911693="" https://www.schwabfunds.com/welcome9?destination="/products/swtsx" https://www.ishares.com/us/products/239724/ishares-core-sp-total-us-stock-market-etf="" fv="P" (="" 1="" +="" r="" k="" )nk="" ︸="" ︷︷="" ︸="" future="" value="" lumpsum="" +="" pmt="" (="" 1="" +="" r="" k="" )nk="" −="" 1="" r/k︸="" ︷︷="" ︸="" ordinary="" annuity="" of="" contribs.="" where:="" •="" fv="futuve" value="" of="" investment="" •="" p="initial" amount="" •="" pmt="periodic" contribution="" made="" at="" the="" end="" of="" each="" period="" •="" r="annual" interest="" rate="" (or="" annual="" rate="" of="" return)="" •="" n="number" of="" years="" •="" k="number" of="" periods="" (k="12" monthly="" contributions,="" k="1" annual="" contributions)="" one="" of="" the="" critical="" ingredients="" to="" calculate="" the="" future="" of="" your="" investment="" is="" the="" annual="" rate="" of="" return="" r.="" the="" issue="" is="" that="" annual="" rates="" of="" return="" when="" investing="" in="" the="" stock="" market="" fluctuate="" every="" year—because="" the="" market="" is="" volatile.="" consequently,="" the="" exact="" answer="" to="" the="" above="" question="" is="" impossible="" to="" know.="" however,="" we="" are="" going="" to="" make="" some="" assumptions,="" and="" run="" some="" simulations="" to="" get="" an="" idea="" of="" the="" behavior="" for="" this="" type="" of="" investment.="" for="" the="" sake="" of="" simplicity,="" we="" will="" ignore="" inflation.="" 2)="" variable="" rates="" of="" return="" and="" volatility="" note:="" this="" section="" provides="" more="" contextual="" information;="" nothing="" to="" calculate="" here.="" for="" simulation="" purposes,="" we="" are="" going="" to="" assume="" a="" probability="" distribution="" on="" the="" rates="" of="" return.="" more="" specifically,="" we="" are="" going="" to="" assume="" that="" annual="" rates="" of="" return="" ry="" follow="" a="" normal="" distribution="" with="" a="" certain="" mean="" µ="" and="" a="" certain="" standard="" deviation="" σ.="" ratey="" ∼="" n="" (µ="avg" rate,="" σ="avg" volatility)="" which="" µ="" and="" which="" σ?="" we="" could="" look="" for="" historical="" data="" and="" use="" an="" average="" annual="" rate="" of="" return="" for="" µ,="" as="" well="" as="" an="" average="" annual="" volatility="" for="" σ.="" fidelity’s="" fskax="" 1="" provides="" an="" average="" annual="" rate="" of="" return="" of="" 10%="" and="" an="" average="" annual="" volatility="" of="" 18%="" (keep="" in="" mind="" that="" these="" values="" correspond="" to="" the="" last="" 3="" years).="" in="" summary,="" let’s="" assume="" that="" annual="" rates="" of="" return="" follow="" a="" normal="" distribution="" with:="" •="" average="" annual="" return:="" µ="10%" •="" average="" annual="" volatility:="" σ="18%" btw:="" with="" your="" shiny="" app,="" you="" will="" be="" able="" to="" modify="" these="" values="" and="" get="" an="" idea="" of="" the="" expected="" returns="" under="" different="" return="" and="" volatility="" conditions.="" 1https://fundresearch.fidelity.com/mutual-funds/summary/315911693="" 2="" https://fundresearch.fidelity.com/mutual-funds/summary/315911693="" 3)="" simulation="" with="" variable="" rates="" of="" return="" note:="" this="" third="" section="" describes="" examples="" that="" will="" guide="" you="" in="" coding="" your="" shiny="" app.="" let’s="" bring="" back="" the="" investing="" scenario="" with="" an="" initial="" amount="" of="" $1000,="" and="" let="" us="" discuss="" two="" investing="" scenarios:="" 1)="" making="" contributions="" at="" the="" end="" of="" every="" year,="" and="" 2)="" making="" contributions="" at="" the="" end="" of="" every="" month.="" contributions="" at="" the="" end="" of="" every="" of="" year="" say="" you="" make="" contributions="" of="" $360="" at="" the="" end="" of="" each="" year,="" during="" a="" 10-year="" period,="" assuming="" that="" annual="" rates="" of="" return="" ry="" have="" a="" normal="" distribution="" with="" the="" following="" parameters:="" ry="" ∼="" n(µ="10%," σ="18%)" with="" variable="" rates="" of="" return,="" we="" can="" no="" longer="" use="" the="" formula="" of="" the="" future="" value="" (fv)="" described="" in="" section="" 1.="" luckily,="" we="" can="" still="" do="" computations.="" here’s="" a="" conceptual="" dia-="" gram="" illustrating="" the="" flow="" of="" the="" investment="" during="" the="" first="" three="" years,="" assuming="" annual="" contributions:="" 1000="" 0="" 1="" 1000(1="" +="" r1)="" +="" 360="amt1" year="1" annual="" return="" year="" 1="" r1=""><- rnorm(1,="" μ,="" σ)="" initial="" amount="" amt0="" amount="" at="" the="" end="" of="" 1st="" year="" amt1="" (amt1)="" (1="" +="" r2)="" +="" 360="amt2" amt2="" annual="" return="" year="" 2="" r2=""><- rnorm(1,="" μ,="" σ)="" 1="" 2="" year="2" 2="" 3="" year="3" (amt2)="" (1="" +="" r3)="" +="" 360="amt3" annual="" return="" year="" 3="" r3=""><- rnorm(1,="" μ,="" σ)="" at="" the="" end="" of="" every="" year="" you="" contribute="" 360="" amount="" at="" the="" end="" of="" 2nd="" year="" amount="" at="" the="" end="" of="" 3rd="" year="" …="" etc="" as="" you="" can="" tell="" from="" the="" figure="" above,="" an="" annual="" rate="" of="" return="" for="" a="" given="" year="" needs="" to="" be="" randomly="" generated—via="" rnorm().="" this="" is="" the="" function="" in="" r="" that="" allows="" you="" to="" generate="" random="" numbers="" from="" a="" normal="" distribution.="" contributions="" at="" the="" end="" of="" every="" of="" every="" month="" if="" the="" contributions="" are="" made="" at="" the="" end="" of="" every="" month,="" then="" the="" conceptual="" diagram="" looks="" like="" the="" figure="" below;="" the="" diagram="" displays="" what="" happens="" in="" the="" first="" year,="" followed="" by="" 3="" the="" beginning="" of="" the="" first="" month="" in="" the="" second="" year="" (i.e.="" 13th="" periodic="" contribution).="" 1000="" 0="" 1="" 1000(1="" +="" r1="" 12)="" +="" 360="amt1" month="1" annual="" return="" year="" 1="" r1=""><- rnorm(1,="" μ,="" σ)="" initial="" amount="" amt0="" amount="" at="" the="" end="" of="" 1st="" month="" amt1="" (amt1)="" (1="" +="" r1="" 12)="" +="" 360="amt2" amt11="" 1="" 2month="2" 11="" 12month="12" (amt11)="" (1="" +="" r1="" 12)="" +="" 360="amt12" annual="" return="" year="" 2="" r2=""><- rnorm(1,="" μ,="" σ)="" at="" the="" end="" of="" every="" month="" you="" contribute="" 360="" at="" the="" end="" of="" 2nd="" month="" at="" the="" end="" of="" 12th="" month…="" etc="" ...="" amt12="" 12="" 13month="13" (amt12)="" (1="" +="" r2="" 12)="" +="" 360="amt13" at="" the="" end="" of="" 13th="" month="" year="" 1="" year="" 2="" …="" etc="" ...="" how="" to="" randomly="" generate="" an="" annual="" rate="" of="" return="" the="" following="" code="" chunk="" shows="" an="" example="" that="" illustrates="" how="" to="" generate="" a="" random="" annual="" return.="" the="" function="" set.seed()="" generates="" a="" random="" seed="" for="" replication="" purposes.="" #="" generate="" a="" random="" annual="" return="" rate="" set.seed(12345)="" #="" random="" seed="" for="" reproducibility="" avg_return=""><- 0.10="" #="" u.s.="" stocks="" annual="" avg="" return="" avg_volatility=""><- 0.18 # u.s. stocks annual avg volatility rnorm(1, mean = avg_return, sd = avg_volatility) ## [1] 0.2053952 3.1) example: running 3 simulations one the goals of this project is to run various simulations that give you a theoretical idea for the behavior of this investment. here’s a toy example with the annual balance of 3 simulations (see table below). the first row (0) shows the initial investment amount of $1000. each year $360 are contributed at the end of the year. the last row (6) shows the balance of the investment at the end of year 5. column 1 corresponds to the 1st simulation, column 2 to the 2nd simulation, 0.18="" #="" u.s.="" stocks="" annual="" avg="" volatility="" rnorm(1,="" mean="avg_return," sd="avg_volatility)" ##="" [1]="" 0.2053952="" 3.1)="" example:="" running="" 3="" simulations="" one="" the="" goals="" of="" this="" project="" is="" to="" run="" various="" simulations="" that="" give="" you="" a="" theoretical="" idea="" for="" the="" behavior="" of="" this="" investment.="" here’s="" a="" toy="" example="" with="" the="" annual="" balance="" of="" 3="" simulations="" (see="" table="" below).="" the="" first="" row="" (0)="" shows="" the="" initial="" investment="" amount="" of="" $1000.="" each="" year="" $360="" are="" contributed="" at="" the="" end="" of="" the="" year.="" the="" last="" row="" (6)="" shows="" the="" balance="" of="" the="" investment="" at="" the="" end="" of="" year="" 5.="" column="" 1="" corresponds="" to="" the="" 1st="" simulation,="" column="" 2="" to="" the="" 2nd="">
Answered 1 days AfterApr 18, 2021

Answer To: # =============================================== # Fill in the following fields #...

Abr Writing answered on Apr 20 2021
140 Votes
# ===============================================
# Fill in the following fields
# ===============================================
# Title: Investment Simulator
# Descriptio
n: A shiny app to run simulations,
# Author:
# Date:
# ===============================================
# Required packages
# ===============================================
library(dplyr)
library(ggplot2)
library(shiny)
library(tidyr)
library(reshape2)
# ...
# Define UI for application that draws a histogram
ui <- fluidPage(

# Application title
titlePanel("Investment Simulator"),

fluidRow(
column(3,
sliderInput("initial",
label = h5("Initial Amount"),
min = 0,
max = 100000,
step = 500,
value = 1000)
),

column(3,
sliderInput("periodic_contribution",
label = h5("Periodic Contribution"),
min = 0,
max = 1000,
step = 10,
value = 360)
),

column(3,
sliderInput("avg_return",
label = h5("Average Annual Return"),
min = 0,
max = 1,
step = 0.01,
value = 0.10)
),

column(3,
sliderInput("num_simulations",
label = h5("Number of Simulations"),
min = 0,
max = 1000,
step = 10,
value = 50)
),

column(3,
sliderInput("num_years",
label =...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here