I have this problem, i downloaded a dataset from yahoo finance,..you can find it here https://finance.yahoo.com/quote/^GSPC/history?p=^GSPC
So I have downloaded the data for the period 2013 to 2018,..and i want to analyse the data in panels as follows:
Panel A: January 2013 - December 2013
Panel B: January 2014 - December 2014
..
..
..
Panel F: January 2018 - December 2018
I can divide the data in excel and load the Panels differently, but that will mean lots of work since i have to run this analysis on 6 Different stock indexes. Furthermore, the actual time frame for my analysis is pretty large [1996 -2016]. What i need help with is to run descriptive analysis on the data showing the statistics for each panel,...then combine the datasets and run regression analysis say 'linear regression" on the data but be able to observe the summary output indexed according to the Panels as outlined above.
Any help will really be appreciated,...or any reference manual or book I can read
I have considered the code you sent,..i should admit my understanding of R is still a little challenged. When i try to run the code, am getting the following error,..
Error: Problem with mutate() input year.
x invalid 'trim' argument
i Input year is format(Data3$Date, "%m/%d/%y").
Run rlang::last_error() to see where the error occurred.
I think its being caused by either me entering the wrong value for "year", or the date_field_name,
if possible please try and plug in the example values, i think this code is just what i need at this juncture
Your suggestion is very straightforward and simple to implement,..but my challenge is I am running an analysis for a 20 year period,..1996 through to 2016,..so what i intend to do is to download the Dataset as a complete set and then run the analysis but using code that takes into consideration the Panel distributions as outlined earlier.
This will get you all the data for a specified stock list for a duration.
suppressPackageStartupMessages({
library(tidyquant)
library(tsibble)
})
indices <- c("AAPL","MSFT","AMZN","GOOGL","FB","TSM","TSLA","BABA","BRK.A","JPM","V","JNJ","WMT","MA","UNH","DIS","NVDA","BAC","HD","PG")
start_year <- "1996-01-01"
to_year <- "2016-12-31"
series <- tq_get(indices, get = "stock.prices", from = base_year, to = to_year)
then the tsibble package has tidyverse-like subsetting, can deal with irregular time series such as stock prices, and is the base class for a rich suite of time series and forecasting analytic tools. See the online text.